package com.freewater.springboot.demo.customlistener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;

@Slf4j
public class MyCustomTestExecutionListener extends AbstractTestExecutionListener implements Ordered {

    @Override
    public int getOrder() {
        return 1001; // 插入到ServletTestExecutionListener之后（ServletTestExecutionListener的order为1000）
    }

    @Override
    public void beforeTestMethod(TestContext testContext) {
        log.info("my test execution listener: before test method, curr test method is {}",
                testContext.getTestMethod().getName());
    }

    @Override
    public void afterTestMethod(TestContext testContext) {
        log.info("my test execution listener: after test method, curr test method is {}",
                testContext.getTestMethod().getName());
    }
}
